# coding=utf-8

#import os
import logging as log

class GtpStringObject:
    def __init__(self, msg_bytes, codec):
        self._codec = codec
        self._content = msg_bytes

        self._start = 0
        self._end = len(msg_bytes)
        self._length = len(msg_bytes)

        self._current = 0
        self._current_key_start = 0
        self._current_key_end = 0

        self._current_value_start = 0
        self._current_value_end = 0
        self._current_value_type = 0

    def length(self):
        return self._length

    @property
    def current(self):
        return self._current

    @property
    def codec(self):
        return self._codec


    def get_key_start(self):
        return self._current_key_start

    def set_key_start(self, index):
        self._current_key_start = index

    def get_key_end(self):
        return self._current_key_end

    def set_key_end(self, index):
        self._current_key_end = index

    def get_value_start(self):
        return self._current_value_start

    def set_value_start(self, index):
        self._current_value_start = index

    def get_value_end(self,index):
        return self._current_value_end

    def set_value_end(self, index):
        self._current_value_end = index

    def current_byte(self):
        return self._content[self._current]

    def current_key(self):
        return self._content[self._current_key_start:self._current_key_end]

    def current_value(self):
        return self._content[self._current_value_start:self._current_value_end]

    def current_type(self):
        return None

    def move_to_next(self):
        self._current += 1 

    def is_end(self):
        return self._current == self._end

    def is_available(self):
        return self._current < self._end

    def is_empty(self):
        return self._length == 0

    def is_pair_separator(self):
        return self._content[self._current] == ord(',')

    def is_kv_separator(self):
        return self._content[self._current] == ord('=')

    def is_array_begin(self):
        return self._content[self._current] == ord('[')
            
    def is_array_end(self):
        return self._content[self._current] == ord(']')
            
    def is_object_begin(self):
        return self._content[self._current] == ord('{')
            
    def is_object_end(self):
        return self._content[self._current] == ord('}')



